﻿using System;
using System.Collections.ObjectModel;

namespace Fabrication.ValueProviders
{
    internal class CollectionValueProvider<T> : ValueProviderBase<Collection<T>>
    {
        private readonly int numberOfItems;

        public CollectionValueProvider(int numberOfItems)
        {
            this.numberOfItems = numberOfItems;
        }

        public CollectionValueProvider(int minimumItems, int maximumItems)
            : this(RandomNumberGenerator.GetInteger(minimumItems, maximumItems)) { }

        protected override Collection<T> GetValue(object item)
        {
            var list = new Collection<T>();

            for (int i = 0; i < numberOfItems; i++)
                list.Add(Activator.CreateInstance<T>());

            return list;
        }
    }
}